package com.msa.msaportal.util;

import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

public class SpringTool {
	
	

	private static WebApplicationContext wac = null;

	public SpringTool() {
		super();
	}

	// 静态工厂方法
	public static WebApplicationContext getApplicationContext() {
		if (wac == null) {
			wac = ContextLoader.getCurrentWebApplicationContext();
		}
		return wac;
	}
	
	public static Object getBean(String args) {
		Object obj = null;
		try {
			obj =  getApplicationContext().getBean(args);

		} catch (Exception e) {
			e.printStackTrace();
		}
		return obj;
	}
}
